package com.example.rocket.annotation;

import com.example.rocket.core.ConsumeMode;
import com.example.rocket.core.SelectorType;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;

import java.lang.annotation.*;

/**
 * @description: 消费者监听注解
 * @author TAO
 * @date 2021/12/21 3:56 下午
 */

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface NbMQMessageListener {


    String NAME_SERVER_PLACEHOLDER = "${rmq.name-server:}";
    String ACCESS_KEY_PLACEHOLDER = "${rmq.access-key:}";
    String SECRET_KEY_PLACEHOLDER = "${rmq.secret-key:}";
    String TRACE_TOPIC_PLACEHOLDER = "${rmq.consumer.customized-trace-topic:}";
    String ACCESS_CHANNEL_PLACEHOLDER = "${rmq.access-channel:}";

    /**
     * NameServer:如果指定则忽略配置文件中的
     */
    String nameServer() default NAME_SERVER_PLACEHOLDER;

    /**
     * Topic 名
     * @return
     */
    String topic();

    /**
     *  等价于 TAG
     */
    String selectorExpression() default "*";

    /**
     * 消费者Group
     * @return
     */
    String consumerGroup();

    /**
     * accessKey
     * @return
     */
    String accessKey() default ACCESS_KEY_PLACEHOLDER;

    /**
     * secretKey
     * @return
     */
    String secretKey() default SECRET_KEY_PLACEHOLDER;

    /**
     * 控制消费模式，您可以选择并发或有序接收消息。
     * @return
     */
    ConsumeMode consumeMode() default ConsumeMode.CONCURRENTLY;

    /**
     * 控制如何选择消息。
     * @return
     */
    SelectorType selectorType() default SelectorType.TAG;

    /**
     * 消息订阅模式
     */
    MessageModel messageModel() default MessageModel.CLUSTERING;

    /**
     * Max consumer thread number.
     */
    int consumeThreadMax() default 64;

    /**
     * 消费超时时间
     */
    long consumeTimeout() default 15L;

    /**
     * Switch flag instance for message trace.
     */
    boolean enableMsgTrace() default true;

    /**
     * The name value of message trace topic.If you don't config,you can use the default trace topic name.
     */
    String customizedTraceTopic() default TRACE_TOPIC_PLACEHOLDER;

    /**
     * The property of "access-channel".
     * @return
     */
    String accessChannel() default ACCESS_CHANNEL_PLACEHOLDER;












}
